package com.org.litepal.slice.crud;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import org.litepal.harmony.ResourceTable;

/**
 * 增删查改
 */
public class CrudAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_crud);

        //保存
        Button btnSave = (Button) findComponentById(ResourceTable.Id_save_sample_btn);
        //更新
        Button btnUpdate = (Button) findComponentById(ResourceTable.Id_update_sample_btn);
        //删除
        Button btnDelete = (Button) findComponentById(ResourceTable.Id_delete_sample_btn);
        //查询
        Button btnQuery = (Button) findComponentById(ResourceTable.Id_query_sample_btn);

        btnSave.setClickedListener(component -> present(new SaveSampleAbilitySlice(), new Intent()));
        btnUpdate.setClickedListener(component -> present(new UpdateSampleAbilitySlice(), new Intent()));
        btnDelete.setClickedListener(component -> present(new DeleteSampleAbilitySlice(), new Intent()));
        btnQuery.setClickedListener(component -> present(new QuerySampleAbilitySlice(), new Intent()));
    }
}